//
//  RootTabBarController.m
//  UIHomeWork_07
//
//  Created by tusm on 16/7/23.
//  Copyright © 2016年 tusm. All rights reserved.
//

#import "RootTabBarController.h"
#import "VCOf1stTabBarItem.h"
#import "VCOf2ndTabBarItem.h"
#import "VCOf3rdTabBarItem.h"
#import "VCOf4thTabBarItem.h"

@interface RootTabBarController ()

@end

@implementation RootTabBarController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        //设置root的viewcontrolelrs属性
        self.viewControllers = [self createRootOfVCs];
    }
    return self;
}

- (NSArray <UIViewController *> *)createRootOfVCs{

    //定义装VC的可变数组
    NSMutableArray *arrOfVCs = [NSMutableArray array];

    #pragma mark - 第一个tabBarItem
    VCOf1stTabBarItem *tabBarItem1 = [[VCOf1stTabBarItem alloc] init];
    UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:tabBarItem1];
    
    navi.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"首页" image:[UIImage imageNamed:@"home"] tag:100];
    [arrOfVCs addObject:navi];
    
    
    #pragma mark - 第二个tabBarItem
    VCOf2ndTabBarItem *tabBarItem2 = [[VCOf2ndTabBarItem alloc] init];
    tabBarItem2.view.backgroundColor = [UIColor redColor];
    [arrOfVCs addObject:tabBarItem2];
    tabBarItem2.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"消息" image:[UIImage imageNamed:@"message"] tag:200];

    
    #pragma mark - 第三个tabBarItem
    VCOf3rdTabBarItem *tabBarItem3 = [[VCOf3rdTabBarItem alloc] init];
    UINavigationController *navi3 = [[UINavigationController alloc] initWithRootViewController:tabBarItem3];
    [arrOfVCs addObject:navi3];
    navi3.view.backgroundColor = [UIColor yellowColor];

    navi3.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"发现" image:[UIImage imageNamed:@"seach"] tag:300];
    
    #pragma mark - 第四个TabBarItem
    VCOf4thTabBarItem *tabBarItem4 = [[VCOf4thTabBarItem alloc] init];
    UINavigationController *navi2 = [[UINavigationController alloc] initWithRootViewController:tabBarItem4];
    [arrOfVCs addObject:navi2];

    navi2.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"我" image:[UIImage imageNamed:@"me"] tag:400];
    
    return arrOfVCs;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
